package org.classg.cms.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.classg.cms.entity.Banner;
import org.classg.cms.service.BannerService;
import org.classg.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(description = "网站首页Banner列表")
@RequestMapping("/bannerFront/banner")
@CrossOrigin
public class BannerFrontController {

    @Autowired
    private BannerService bannerService;

    @Cacheable(key = "'queryAllBanner'", value = "banners")// redis注解
    @ApiOperation("查询首页Banner")
    @GetMapping("/queryAllBanner")
    public R queryAllBanner() {
        List<Banner> banners = bannerService.list(null);
        return R.ok().data("items", banners);
    }
}
